package com.jame.basics.thread.gather;


import
        java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.CopyOnWriteArrayList;


/**
 * @author : Jame
 * @date : 2021-01-11 12:24
 **/
public class Test1 {
    public static void main(String[] args) {
        //不安全
        List<String> list = new ArrayList<>();

        new Vector<String>();
        Collections.synchronizedList(new ArrayList<String>());
        //list和set都有CopyOnWrite  map使用ConcurrentHashMap
        new CopyOnWriteArrayList<String>();


        for (int i = 0; i < 50; i++) {
            new Thread(()->{
                list.add("aaa");
                System.out.println(list);
            },"线程:"+i).start();
        }
    }
}
